package org.example.attendancesystem.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.servlet.http.HttpServletResponse;
import org.apache.poi.hssf.usermodel.*;
import org.example.attendancesystem.domain.*;
import org.example.attendancesystem.domain.vo.AttendanceRecordWithTitleVO;
import org.example.attendancesystem.mapper.AttendanceRecordsMapper;
import org.example.attendancesystem.service.AttendanceRecordsService;
import org.example.attendancesystem.service.SessionParamsService;
import org.example.attendancesystem.service.StudentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;


@CrossOrigin
@RestController
@RequestMapping("/student")
public class StudengControlller {

    @Autowired
    private StudentsService studentsService;

    @GetMapping("signIn")
    public Result<Students> signIn(@RequestParam("studentId") String studentId, @RequestParam("password") String password) {
        QueryWrapper<Students> queryWrapper = new QueryWrapper<Students>()
                .eq("student_id", studentId)
                .eq("password_hash",password);
        System.out.println(studentId);
//        System.out.println(password);
        Students students = studentsService.getOne(queryWrapper);

        if(students != null){
            return Result.success(students);
        }else {
            return Result.fail("用户名或密码错误");
        }

    }
}
